<template>
  <section>
    <!--工具条-->
    <el-col :span="24" class="toolbar" style="padding-bottom: 0px;padding-left:0px;">
      <el-form :inline="true">
        <el-form-item>
          <el-input v-model="search_taskname" placeholder="任务名称" v-show="!mxym_drawer"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="search_task()" v-show="!mxym_drawer">查询</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="add_task();t_getopinions();get_pdmfiles()" v-show="!mxym_drawer">新增</el-button>
        </el-form-item>
        <el-form-item  v-show="!mxym_drawer">
          <el-upload
            class="upload-demo"
            :action="UploadUrl()"

          >
            <el-button size="small" type="success">上传pdm文件</el-button>
          </el-upload>

        </el-form-item>

        <el-form-item style="padding-bottom: 0px;">

          <el-button type="primary" size="mini" round icon="el-icon-caret-left" v-show='mxym_drawer'
                     @click="mxym_drawer=!mxym_drawer;
        ts_col  =true;
        ts_type =true;
        ts_len  =true;
        ts_uk   =true;
        tp_col  =true;
        tp_type =true;
        tp_len  =true;
        tp_uk   =true;
        currentPage=1;
        pagesize=10
"></el-button>
          <el-button v-show='mxym_drawer' size="mini" type="success" round icon="el-icon-download"
                     @click="exportExcel"></el-button>
          <el-button v-show='mxym_drawer' size="mini" type="primary" round icon="el-icon-search"
                     @click="Mxck_all"></el-button>
        </el-form-item>
      </el-form>
    </el-col>
    <!--列表-->
    <el-table
              :data="tableData.slice((currentPage-1)*pagesize,currentPage*pagesize)"
              stripe height="600"
              highlight-current-row style="width: 100%;"
              v-show='!mxym_drawer'
              max-height="500"

    >
      <el-table-column type="selection" width="55">
      </el-table-column>

      <el-table-column type="index" width="60">
      </el-table-column>
      <el-table-column prop="task_name" disabled label="任务名称" width="100" align="center" show-overflow-tooltip>
        <template slot-scope="scope">
          <el-button type="text" @click="handleShow(scope.row.fields)"> {{ scope.row.fields.task_name }}</el-button>
        </template>
      </el-table-column>

      <el-table-column prop="task_state" label="任务状态" width="100" align="center">
        <template slot-scope="scope"> {{ scope.row.fields.task_state|state_tran }}</template>
      </el-table-column>

      <el-table-column prop="oracle_connection" label="数据库" width="100" align="center" show-overflow-tooltip>
        <template slot-scope="scope"> {{ scope.row.fields.oracle_connection }}</template>
      </el-table-column>
      <el-table-column prop="oracle_connection" label="pdm文件" show-overflow-tooltip width="160" align="center">
        <template slot-scope="scope"> {{ scope.row.fields.pdm_file }}</template>
      </el-table-column>
      <el-table-column prop="last_execute_time" label="上次执行" width="100" align="center" show-overflow-tooltip>
        <template slot-scope="scope"> {{ scope.row.fields.last_execute_time }}</template>
      </el-table-column>

      <el-table-column prop="job_names" label="测试JOB" width="250" align="center" show-overflow-tooltip>
        <template slot-scope="scope"> {{ scope.row.fields.job_names }}</template>
      </el-table-column>

      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button type="success" size="small" @click="Mxck(scope.row.fields)">查看</el-button>
          <el-button type='primary' size="small" @click="handleEdit(scope.row.fields);t_getopinions();get_pdmfiles()">编辑</el-button>
          <el-button type="danger" size="small" @click="handleDel(scope.row.fields)">删除</el-button>
          <el-button type="success" size="small" @click="handleImp(scope.row.fields)">执行</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[10, 20, 40]"
      :page-size="pagesize"
      v-show='!mxym_drawer'
      layout="total, sizes, prev, pager, next, jumper"
      :total="tableData.length">
    </el-pagination>
    <!--查看页面-->
    <el-drawer
      title="任务查看"
      :visible.sync="show_drawer"
      direction="ltr"
    >
      <el-card class="box-card" shadow="always">
        <el-form :model="showForm" label-width="150px" :rules="addFormRules" ref="showForm">
          <el-form-item label="任务名称" prop="task_name">
            <el-input disabled v-model="showForm.task_name"></el-input>
          </el-form-item>
          <el-form-item label="任务状态" prop="task_state">
            <span><font color="#ababab">{{showForm.task_state|state_tran}}</font></span>
          </el-form-item>
          <el-form-item label="数据库链接" prop="oracle_connection">
            <span><font color="#ababab">{{showForm.oracle_connection}}</font></span>
          </el-form-item>
          <el-form-item label="pdm文件" prop="pdm_file">
            <span><font color="#ababab">{{showForm.pdm_file}}</font></span>
          </el-form-item>

          <el-form-item label="上次执行时间" prop="last_execute_time">
            <span><font color="#ababab">{{showForm.last_execute_time}}</font></span>
          </el-form-item>
          <el-form-item label="测试JOB" prop="job_names">
            <el-input type="textarea" v-model="showForm.job_names" disabled></el-input>
          </el-form-item>
        </el-form>
      </el-card>
    </el-drawer>

    <!--编辑页面-->
    <el-drawer
      title="任务编辑"
      :visible.sync="eidt_drawer"
    >
      <el-card class="box-card" shadow="always">
        <el-form :model="editForm" label-width="150px" ref="editForm">
          <el-form-item label="任务名称" prop="task_name">
            <el-input disabled v-model="editForm.task_name"></el-input>
          </el-form-item>

          <el-form-item label="任务状态" disabled prop="task_state">
            <span><font color="#ababab">{{editForm.task_state|state_tran}}</font></span>
          </el-form-item>

          <el-form-item label="数据库链接" prop="oracle_connection">
            <!--<el-input v-model="addForm.oracle_connection" ></el-input>-->
            <el-select v-model="editForm.oracle_connection" placeholder="请选择数据库链接">
              <el-option
                v-for="item in t_options"
                :key="item.fields.db_name"
                :label="item.fields.db_name"
                :value="item.fields.db_name">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="选择pdm文件" prop="pdm_file">
            <!--<el-input v-model="addForm.oracle_connection" ></el-input>-->
            <el-select v-model="editForm.pdm_file" placeholder="请选择pdm文件">
              <el-option
                v-for="item in pdm_files"
                :key="item"
                :label="item"
                :value="item">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="上次执行时间" prop="last_execute_time">
            <span><font color="#ababab">{{editForm.last_execute_time}}</font></span>
          </el-form-item>
          <el-form-item label="测试JOB" prop="job_names">
            <el-input type="textarea" v-model="editForm.job_names"></el-input>
          </el-form-item>
        </el-form>
      </el-card>
      <el-card>
        <el-button @click.native="eidt_drawer = false" size="small">取消</el-button>
        <el-button type="primary" size="small" @click="eidtsub">提交</el-button>
      </el-card>
    </el-drawer>

    <!--新增界面-->
    <el-dialog title="新增任务"
               :visible.sync="addFormVisible"
               :close-on-click-modal="false"
               v-show="addFormVisible"
               width="30">

      <el-form :model="addForm" label-width="150px" :rules="addFormRules" ref="addForm" label-position="left">
        <el-form-item label="任务名" prop="task_name">
          <el-input v-model="addForm.task_name"></el-input>
        </el-form-item>
        <el-form-item label="数据库链接" prop="oracle_connection">
          <!--<el-input v-model="addForm.oracle_connection" ></el-input>-->
          <el-select v-model="addForm.oracle_connection" placeholder="请选择数据库链接">
            <el-option
              v-for="item in t_options"
              :key="item.fields.db_name"
              :label="item.fields.db_name"
              :value="item.fields.db_name">
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="选择pdm文件" prop="pdm_file">
          <!--<el-input v-model="addForm.oracle_connection" ></el-input>-->
          <el-select v-model="addForm.pdm_file" placeholder="请选择pdm文件">
            <el-option
              v-for="item in pdm_files"
              :key="item"
              :label="item"
              :value="item">
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="测试JOB" prop="job_names">
          <el-input type="textarea" v-model="addForm.job_names"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click.native="addFormVisible = false">取消</el-button>
        <el-button type="primary"
                   @click.native="addSubmit"
        >提交
        </el-button>
      </div>
    </el-dialog>

    <!--明细页面-->
    <el-table :data="mxData.slice((currentPage-1)*pagesize,currentPage*pagesize)"
              highlight-current-row style="width: 100%;"
              v-show='mxym_drawer'
              max-height="490"
              min-height="490"
              id="out-table2"
              size="mini"
    >



      <el-table-column prop="job_name" label="JOB名称" align="center" show-overflow-tooltip width="200">
        <template slot-scope="scope"> {{ scope.row.fields.job_name }}</template>
      </el-table-column>

      <el-table-column prop="t_tab" label="目标表" align="center" show-overflow-tooltip>
        <template slot-scope="scope"> {{ scope.row.fields.t_tab }}</template>
      </el-table-column>


      <el-table-column prop="t_column" label="目标字段" align="center" show-overflow-tooltip>
        <template slot-scope="scope"> {{ scope.row.fields.t_column }}</template>
      </el-table-column>
      <el-table-column prop="p_column" label="PDM字段" align="center" show-overflow-tooltip>
        <template slot-scope="scope"> {{ scope.row.fields.p_column }}</template>
      </el-table-column>

      <el-table-column label="目标表与pdm文件结构对比测试" align="center" v-if="tp_col">

        <el-table-column prop="tp_col_join" width="150" label="目标字段||pdm字段" align="center" show-overflow-tooltip
        >
          <template slot-scope="scope"> {{ scope.row.fields.tp_col_join}}</template>
        </el-table-column>

        <el-table-column prop="tp_col_result" label="测试结果" align="center" width="118"
        >
          <template slot-scope="scope">

            <!--<el-tag-->
            <!--:type="scope.row.fields.tp_col_result === 'FAIL' ? 'danger' : 'success'"-->
            <!--close-transition>{{scope.row.fields.tp_col_result}}</el-tag>-->
            <el-select v-model="scope.row.fields.tp_col_result"
                       :class="{'result-pass':scope.row.fields.tp_col_result=='PASS','result-fail':scope.row.fields.tp_col_result=='FAIL'}"

                       @change="Mxxg(scope.row.fields)">
              <el-option
                v-for="item in test_res"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </template>
        </el-table-column>
      </el-table-column>


      <el-table-column label="目标表与pdm字段类型测试" align="center" v-if="tp_type">

        <el-table-column prop="tp_col_type_join" width="150" label="目标类型||pdm类型" align="center" show-overflow-tooltip
        >
          <template slot-scope="scope"> {{ scope.row.fields.tp_col_type_join}}</template>
        </el-table-column>

        <el-table-column prop="tp_col_type_result" label="测试结果" align="center" width="118"
        >
          <template slot-scope="scope">
            <!--<el-tag-->
            <!--:type="scope.row.fields.tp_col_type_result === 'FAIL' ? 'danger' : 'success'"-->
            <!--close-transition>{{scope.row.fields.tp_col_type_result}}</el-tag>-->
            <el-select v-model="scope.row.fields.tp_col_type_result"
                       :class="{'result-pass':scope.row.fields.tp_col_type_result=='PASS','result-fail':scope.row.fields.tp_col_type_result=='FAIL'}"

                       @change="Mxxg(scope.row.fields)">
              <el-option
                v-for="item in test_res"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </template>
        </el-table-column>
      </el-table-column>


      <el-table-column label="目标表与pdm字段长度测试" align="center" v-if="tp_len">

        <el-table-column prop="tp_col_lenth_join" width="150" label="目标长度||pdm长度" align="center" show-overflow-tooltip
        >
          <template slot-scope="scope"> {{ scope.row.fields.tp_col_lenth_join}}</template>
        </el-table-column>
        <el-table-column prop="tp_col_lenth_result" label="测试结果" align="center" width="118"
        >
          <template slot-scope="scope">

            <!--<el-tag-->
            <!--:type="scope.row.fields.tp_col_lenth_result === 'FAIL' ? 'danger' : 'success'"-->
            <!--close-transition>{{scope.row.fields.tp_col_lenth_result}}</el-tag>-->
            <el-select v-model="scope.row.fields.tp_col_lenth_result"
                       :class="{'result-pass':scope.row.fields.tp_col_lenth_result=='PASS','result-fail':scope.row.fields.tp_col_lenth_result=='FAIL'}"

                       @change="Mxxg(scope.row.fields)">
              <el-option
                v-for="item in test_res"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </template>
        </el-table-column>
      </el-table-column>

      <el-table-column label="目标表与pdm字段主键测试" align="center" v-if="tp_uk">

        <el-table-column prop="tp_col_uk_join" label="目标主键||pdm主键" width="150" align="center" show-overflow-tooltip
        >
          <template slot-scope="scope"> {{ scope.row.fields.tp_col_uk_join}}</template>
        </el-table-column>

        <el-table-column prop="tp_col_uk_result" label="测试结果" align="center" width="118"
        >
          <template slot-scope="scope">

            <!--<el-tag-->
            <!--:type="scope.row.fields.tp_col_uk_result === 'FAIL' ? 'danger' : 'success'"-->
            <!--close-transition>{{scope.row.fields.tp_col_uk_result}}</el-tag>-->
            <el-select v-model="scope.row.fields.tp_col_uk_result"
                       :class="{'result-pass':scope.row.fields.tp_col_uk_result=='PASS','result-fail':scope.row.fields.tp_col_uk_result=='FAIL'}"

                       @change="Mxxg(scope.row.fields)">
              <el-option
                v-for="item in test_res"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </template>
        </el-table-column>
      </el-table-column>


    </el-table>

    <el-table :data="mxData"
              stripe height="600"
              highlight-current-row style="width: 100%;"
              border
              v-show=false
              max-height="500"
              id="out-table"
    >
      <el-table-column prop="job_name" label="JOB名称" align="center" show-overflow-tooltip width="200">
        <template slot-scope="scope"> {{ scope.row.fields.job_name }}</template>
      </el-table-column>

      <el-table-column prop="t_tab" label="目标表" align="center" show-overflow-tooltip>
        <template slot-scope="scope"> {{ scope.row.fields.t_tab }}</template>
      </el-table-column>


      <el-table-column prop="t_column" label="目标字段" align="center" show-overflow-tooltip>
        <template slot-scope="scope"> {{ scope.row.fields.t_column }}</template>
      </el-table-column>
      <el-table-column prop="p_column" label="PDM字段" align="center" show-overflow-tooltip>
        <template slot-scope="scope"> {{ scope.row.fields.p_column }}</template>
      </el-table-column>
      <el-table-column label="目标表与pdm文件结构对比测试" align="center" v-if="tp_col">

        <el-table-column prop="tp_col_join" width="150" label="目标字段||pdm字段" align="center" show-overflow-tooltip
        >
          <template slot-scope="scope"> {{ scope.row.fields.tp_col_join}}</template>
        </el-table-column>

        <el-table-column prop="tp_col_result" label="测试结果" align="center" width="118"
        >
          <template slot-scope="scope"> {{ scope.row.fields.tp_col_result }}</template>

        </el-table-column>
      </el-table-column>


      <el-table-column label="目标表与pdm字段类型测试" align="center" v-if="tp_type">

        <el-table-column prop="tp_col_type_join" width="150" label="目标类型||pdm类型" align="center" show-overflow-tooltip
        >
          <template slot-scope="scope"> {{ scope.row.fields.tp_col_type_join}}</template>
        </el-table-column>

        <el-table-column prop="tp_col_type_result" label="测试结果" align="center" width="118"
        >
          <template slot-scope="scope"> {{ scope.row.fields.tp_col_type_result }}</template>

        </el-table-column>
      </el-table-column>


      <el-table-column label="目标表与pdm字段长度测试" align="center" v-if="tp_len">

        <el-table-column prop="tp_col_lenth_join" width="150" label="目标长度||pdm长度" align="center" show-overflow-tooltip
        >
          <template slot-scope="scope"> {{ scope.row.fields.tp_col_lenth_join}}</template>
        </el-table-column>
        <el-table-column prop="tp_col_lenth_result" label="测试结果" align="center" width="118"
        >
          <template slot-scope="scope"> {{ scope.row.fields.tp_col_lenth_result }}</template>

        </el-table-column>
      </el-table-column>

      <el-table-column label="目标表与pdm字段主键测试" align="center" v-if="tp_uk">

        <el-table-column prop="tp_col_uk_join" label="目标主键||pdm主键" width="150" align="center" show-overflow-tooltip
        >
          <template slot-scope="scope"> {{ scope.row.fields.tp_col_uk_join}}</template>
        </el-table-column>

        <el-table-column prop="tp_col_uk_result" label="测试结果" align="center" width="118"
        >
          <template slot-scope="scope"> {{ scope.row.fields.tp_col_uk_result }}</template>

        </el-table-column>
      </el-table-column>

    </el-table>

    <el-pagination
      v-show='mxym_drawer'
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[5, 10, 20, 40]"
      :page-size="pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="mxData.length">
    </el-pagination>
  </section>
</template>

<script>
  import FileSaver from "file-saver";
  import XLSX from "xlsx";
import {updateBjgTasks,addBjgTasks,getPdmFiles,getOracledbs,uploadFileUrl,getBjgTasks,
  getBjgTaskMxxx,getBjgTaskMxxxAll,updateBjgTaskMxxx,implementBjgTask,deleteBjgTasks} from '../../api/etl_test_requests'
  export default {
    name: "bjg_test",
    data() {
      return {
        uploadurl:'',
        dialogVisible: false,
        currentPage: 1, //初始页
        pagesize: 10,    //    每页的数据
        ts_col: true,
        ts_type: true,
        ts_len: true,
        ts_uk: true,
        tp_col: true,
        tp_type: true,
        tp_len: true,
        tp_uk: true,
        search: '',
        tableData: [],
        mxData: [],
        addFormVisible: false,
        editFormVisible: false,
        listLoading: false,
        show_drawer: false,
        eidt_drawer: false,
        search_taskname: '',
        value: '',
        options: [],
        test_res: [{
          value: 'PASS',
          label: 'PASS'
        }, {
          value: 'FAIL',
          label: 'FAIL'
        }],
        t_options: [],
        pdm_files:[],
        mxym_drawer: false,
        taskmxForm: {
          task_name: ''
        },
        addForm: {
          task_name: '',
          task_state: '',
          oracle_connection: '',
          pdm_file:'',
          job_names: '',
        },
        editForm: {
          task_name: '',
          task_state: '',
          oracle_connection: '',
          pdm_file:'',
          job_names: '',
        },
        showForm: {
          task_name: '',
          task_state: '',
          oracle_connection: '',
          pdm_file:'',
          job_names: '',
        },
        deleteForm: {
          task_name: '',
        },
        implementForm: {
          task_name: '',
          task_state: '',
          oracle_connection: '',
          pdm_file:'',
          job_names: '',
          last_execute_time: '',
        },
        addLoading: false,
        addFormRules: {
          task_name: [
            {required: true, message: '请输入任务名', trigger: 'blur'}
          ]
        },
      }
    },
    methods: {

      UploadUrl:function(){
        this.uploadurl=uploadFileUrl;
        return this.uploadurl;
        console.log(this.uploadurl);
      },
      handleSizeChange: function (size) {
        this.pagesize = size;
        console.log(this.pagesize)  //每页下拉显示数据
      },
      handleCurrentChange: function (currentPage) {
        this.currentPage = currentPage;
        console.log(this.currentPage)  //点击第几页
      },

      exportExcel() {

        let fix = document.querySelector('.el-table__fixed');
        let wb;
        if (fix) { //判断要导出的节点中是否有fixed的表格，如果有，转换excel时先将该dom移除，然后append回去
          wb = XLSX.utils.table_to_book(document.querySelector('#out-table').removeChild(fix));
          document.querySelector('#out-table').appendChild(fix);
        } else {
          wb = XLSX.utils.table_to_book(document.querySelector('#out-table'));
        }
        let wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: true, type: 'array'})
        try {
          FileSaver.saveAs(new Blob([wbout], {type: 'application/octet-stream'}), 'test_result.xlsx')
        } catch (e) {
          if (typeof console !== 'undefined') console.log(e, wbout)
        }
        return wbout
      },

      csh() {
          getBjgTasks({  // 此处名字不可更改
            content: this.search,  // 这里才是真正传递的参数
          }).then((response) => {
          var res = response['data'].list
          this.tableData = res
          console.log(res)
        });

      },

      add_task: function () {
        this.addFormVisible = true
        this.addForm = {
          task_name: '',
          task_state: '',
          oracle_connection: '',
          job_names: '',
        }
      },
      handleShow: function (info) {
        this.show_drawer = true;
        this.showForm = info
      },
      handleEdit: function (info) {
        this.eidt_drawer = true;
        this.editForm = info
      },
      open_mx: function (info) {

        this.$alert(info, '详情', {
          confirmButtonText: '确定'
        });
      },
      Mxck: function (row) {

        this.taskmxForm.task_name = row.task_name
        getBjgTaskMxxx(this.taskmxForm).then((response) => {
          var res = response['data'].list
          this.mxData = res;
          this.mxym_drawer = true;
          console.log(res)
        });
      },
      Mxck_all: function () {
          getBjgTaskMxxxAll(this.taskmxForm).then((response) => {
          var res = response['data'].list
          this.mxData = res;
          this.mxym_drawer = true;
          console.log(res)
        });
      },

      Mxxg: function (row) {
          updateBjgTaskMxxx(row).then((response) => {
          // this.Mxck(row)
        });
      },
      handleImp: function (row) {

        this.$confirm('确认执行该任务吗?', '提示', {
          type: 'warning'
        }).then(() => {
          this.$message.success('任务开始执行');
          this.csh();
          this.implementForm = row
          implementBjgTask(this.implementForm).then
        }).catch(() => {
          this.$message.success('取消执行');
        });

      },
      handleDel: function (row) {
        this.$confirm('确认删除该记录吗?', '提示', {
          type: 'warning'
        }).then(() => {
          this.deleteForm.task_name = row.task_name
          deleteBjgTasks(this.deleteForm).then((response) => {
            var res = response['data'];
            if (res.msg === 'success') {
              this.editFormVisible = false;
              this.$message.success('删除成功');
              this.csh()
            }
            else {
              this.$message.error('删除失败，请联系管理员');
            }
            console.log(res)
          })
        }).catch(() => {
        });
      },

      getopinions() {

        getOracledbs({  // 此处名字不可更改
          content: this.search,   // 这里才是真正传递的参数
        }).then((response) => {
          var res = response['data'].list
          this.options = res
          console.log(res)
        })

      },
      t_getopinions() {
        getOracledbs({  // 此处名字不可更改
          content: this.search,   // 这里才是真正传递的参数
        }).then((response) => {
          var res = response['data'].list
          this.t_options = res
          console.log(res)
        })

      },
      get_pdmfiles()
      {
        getPdmFiles().then((response) => {
          var res = response['data'].list
          this.pdm_files = res
          console.log(res)
        })

      },

      addSubmit() {
        addBjgTasks(this.addForm).then((response) => {
            var res = response['data'];
            if (res.msg === 'success') {
              this.addFormVisible = false;
              this.$message.success('添加成功');
              this.csh()
            }
            else {
              this.$message.error('添加失败，请确保任务名不重复');
            }
            console.log(res);
            console.log(this.editForm)
          })

      },
      eidtsub() {
          updateBjgTasks(this.editForm).then((response) => {
            var res = response['data'];
            if (res.msg === 'success') {
              this.eidt_drawer = false;
              this.$message.success('保存成功');
              this.csh()
            }
            else {
              this.$message.error('保存失败');
            }
            console.log(res);
            console.log(this.editForm)
          })
      },
      search_task() {
          getBjgTasks({  // 此处名字不可更改
            content: this.search_taskname,   // 这里才是真正传递的参数
          }).then((response) => {
          var res = response['data'].list
          this.tableData = res
          console.log(res)
        })
      },
    },
    filters: {
      formatDate: function (value) {
        let date = new Date(value);
        let y = date.getFullYear();
        let MM = date.getMonth() + 1;
        MM = MM < 10 ? ('0' + MM) : MM;
        let d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        let h = date.getHours();
        h = h < 10 ? ('0' + h) : h;
        let m = date.getMinutes();
        m = m < 10 ? ('0' + m) : m;
        let s = date.getSeconds();
        s = s < 10 ? ('0' + s) : s;
        return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s;
      },
      naiped: function (value) {
        return value.slice(0, 30) + '...';
      },
      state_tran: function (value) {
        var value_tran = ''

        if (value === '0') {
          value_tran = '未开始'
        }
        else if (value === '-1') {
          value_tran = '失败'
        }
        else if (value === '99') {
          value_tran = '执行中'
        }
        else {
          value_tran = '成功'
        }
        return value_tran
      }
    },
    created() {
      this.csh()
    },

  }
</script>

<style scoped>

</style>
<style>
  .result-fail input {
    background-color: #fcefef;
    color: #f480af;
  }

  .result-pass input {
    background-color: #eff8ea;
    color: #72c260;
  }
</style>
